<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class AddIndexTypeVersionIdInNoteEntityRelationTable extends AbstractMigration
{
    public function up()
    {
        $this->table('note_entity_relation')
            ->addIndex(['relation_type', 'version_id'], ['name' => 'idx_relation_type_version_id', 'type' => 'normal'])
            ->addIndex(['relation_type', 'task_id'], ['name' => 'idx_relation_type_task_id', 'type' => 'normal'])
            ->addIndex(['relation_type', 'project_id', 'episode_code'], ['name' => 'idx_relation_type_project_id_episode_code', 'type' => 'normal'])
            ->addIndex(['relation_type', 'entity_id'], ['name' => 'idx_relation_type_entity_id', 'type' => 'normal'])
            ->save();
    }

    public function down()
    {
        $this->table('note_entity_relation')
            ->removeIndexByName('idx_relation_type_version_id')
            ->removeIndexByName('idx_relation_type_task_id')
            ->removeIndexByName('idx_relation_type_project_id_episode_code')
            ->removeIndexByName('idx_relation_type_entity_id')
            ->save();
    }
}
